/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

#ifndef PROPERTY_BROWSER_H
#define PROPERTY_BROWSER_H

#include "ClassInfo.h"
#include "Communicator.h"
#include "Entity.h"
#include "widgets/ComponentTreeWidgetItem.h"
#include "widgets/EntityTreeWidgetItem.h"

#include<QCompleter>
#include<QDockWidget>
#include<QTreeView>
#include<QTreeWidget>

class QtAbstractPropertyBrowser;
class QtBoolPropertyManager;
class QtDoublePropertyManager;
class QtGroupPropertyManager;
class QtIntPropertyManager;
class QtPointFPropertyManager;
class QtProperty;
class QtStringPropertyManager;
class QUndoStack;

class PropertyBrowser : public QDockWidget
{
    Q_OBJECT

public:
    PropertyBrowser(QWidget *parent, Communicator *communicator, QUndoStack *undoStack );

    //Clears all the properties of the property browser.
    void clearProperties();

signals:

public slots:
    void onComponentData( QString name, QMap<QString, QVariant> &properties );

private slots:
    void valueChanged( QtProperty *property, double value, double oldValue );
    void valueChanged( QtProperty *property, const QString &value, const QString &oldValue );
    void valueChanged( QtProperty *property, const QPointF &value, const QPointF &oldValue );
    void valueChanged( QtProperty *property, const bool value, const bool oldValue );
    void valueChanged( QtProperty *property, const int value, const int oldValue );

private:
    void init();

    Communicator    *communicator;
    QUndoStack      *undoStack;

    QtAbstractPropertyBrowser   *propertyBrowser;
    QtGroupPropertyManager      *groupManager;

    QtDoublePropertyManager *doubleManager;
    QtStringPropertyManager *stringManager;
    QtPointFPropertyManager *pointManager;
    QtIntPropertyManager    *intManager;
    QtBoolPropertyManager   *boolManager;

    QMap<QtProperty*, QString> propertyToComponentName;

    bool parsingEntityData;
};

#endif
